package com.bank.backend.boot.base.enums;

import java.util.Arrays;

/**
 * @author jiaowei
 * @since 2025/5/8 16:37
 */
public enum TradeEnum {

    TYPE_0(0, "Transfer"),
    TYPE_1(1, "Withdrawal"),
    TYPE_2(2, "Bill Payment"),
    TYPE_3(3, "Debit"),
    TYPE_4(4, "Credit"),
    RISK_0(0, "正常"),
    RISK_1(1, "低风险"),
    RISK_2(2, "中风险"),
    RISK_3(3, "高风险"),
    Finish_0(0, "流程中"),
    Finish_1(1, "已完成"),
    Finish_2(2, "未完成")
    ;


    private final int code;
    private final String desc;

    TradeEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    // TODO 学习
    public static TradeEnum getByDesc(String transactionType) {
        return Arrays.stream(values())
                .filter(e -> e.desc.equals(transactionType))
                .findFirst()
                .orElse(null);
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }
}
